{
capture drop sample
gen sample=(n_ud==1 & S_pds==1)

label var D_sourcing "\$Relational^D_b\$" 
label var S_sourcing "\$Relational_b\$" 

eststo clear

eststo: reghdfe ln_p_inpf_sbjo   S_sourcing   ///
if sample==1, ///
abs(gr_sjt) vce (cluster b_id)
  quietly estadd local CTRL =".", replace  
  quietly estadd local est ="OLS", replace  
  quietly estadd local FE ="sjt", replace  
  quietly estadd local CTRL2 ="Yes", replace    
  quietly estadd scalar  U =  . , replace   

eststo: reghdfe ln_p_inpf_sbjo  S_sourcing  ln_q_sb_all sh_s_b sh_b_s age_buysel_month  ///
 ln_q_b_all age_buy_month  ln_q_inpf signatory ///
if sample==1, ///
abs(gr_sjt top_dest_b cohort_sb cohort_b) vce (cluster b_id)
  quietly estadd local CTRL ="\scriptsize{B,R,O}", replace  
  quietly estadd local est ="OLS", replace  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd local CTRL2 ="Yes", replace    
  quietly estadd scalar  U =  . , replace 

eststo: reghdfe w_r   S_sourcing   ///
if sample==1, ///
abs(gr_sjt ) vce (cluster b_id)
  quietly estadd local CTRL =".", replace  
  quietly estadd local est ="OLS", replace  
  quietly estadd local FE ="sjt", replace  
  quietly estadd local CTRL2 ="Yes", replace    
  quietly estadd scalar  U =  . , replace   

eststo: reghdfe w_r  S_sourcing  ln_q_sb_all sh_s_b sh_b_s age_buysel_month  ///
 ln_q_b_all age_buy_month  ln_p_inpf_sbjo signatory ///
if sample==1, ///
abs(gr_sjt top_dest_b cohort_sb cohort_b) vce (cluster b_id)
  quietly estadd local CTRL ="\scriptsize{B,R,O}", replace  
  quietly estadd local est ="OLS", replace  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd local CTRL2 ="Yes", replace    
  quietly estadd scalar  U =  . , replace 

eststo: reghdfe ln_numf_HS6_UD_imp   S_sourcing   ///
if sample==1, ///
abs(gr_sjt) vce (cluster b_id)
  quietly estadd local CTRL =".", replace  
  quietly estadd local est ="OLS", replace  
  quietly estadd local FE ="sjt", replace  
  quietly estadd local CTRL2 ="Yes", replace    
  quietly estadd scalar  U =  . , replace   

eststo: reghdfe ln_numf_HS6_UD_imp  S_sourcing  ln_q_sb_all sh_s_b sh_b_s age_buysel_month  ///
 ln_q_b_all age_buy_month  ln_p_inpf_sbjo ln_q_sbjo signatory ///
if sample==1, ///
abs(gr_sjt top_dest_b cohort_sb cohort_b) vce (cluster b_id)
  quietly estadd local CTRL ="\scriptsize{B,R,O}", replace  
  quietly estadd local est ="OLS", replace  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd local CTRL2 ="Yes", replace    
  quietly estadd scalar  U =  . , replace 

esttab using "${tables}\Table4.tex", ///
  label replace booktabs b(3) se(3) noconstant obslast substitute(\_ _) ///
  title("Buyers' Sourcing and Input Usage" \label{MaterialsUsage}) ///
  drop(ln_q_b_all ln_q_sb_all sh_s_b sh_b_s age_buysel_months  age_buy_months ln_p_inpf_sbjo ln_q_sbjo ln_q_inpf signatory _cons) order( ) /// 
  stats(FE CTRL r2   N   , fmt( %~#s  %~#s 2 %12.0fc  )  ///
  labels("FEs" "Controls" `"\(R^{2}\)"'  "Obs."  ))   ///
  star(* 0.10 ** 0.05 *** 0.01) ///
  nonotes  	

}
